package com.example.springbootsecurityjwt.controller;

import com.example.springbootsecurityjwt.common.ResponseResult;
import com.example.springbootsecurityjwt.domain.User;
import com.example.springbootsecurityjwt.service.LoginServcie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**

 * @author  supan

 * @create  2022/3/22 13:06

 * @desc    登录接口

 **/
@RestController
public class LoginController {

    private final LoginServcie loginServcie;

    public LoginController(LoginServcie loginServcie) {
        this.loginServcie = loginServcie;
    }


    /**
     * 登录请求
     * @param user
     * @return
     */
    @PostMapping("/user/login")
    public ResponseResult login(@RequestBody User user){
        return loginServcie.login(user);
    }

    @RequestMapping("/user/logout")
    public ResponseResult logout() {
        return loginServcie.logout();
    }
}
